home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / c / assign.c next >
C/C++ Source or Header  |  1996-09-13  |  1KB  |  54 lines

  1. #include <exec/memory.h>
  2. #include <exec/execbase.h>
  3. #include <clib/exec_protos.h>
  4. #include <dos/dos.h>
  5. #include <clib/dos_protos.h>
  6. #include <utility/tagitem.h>
  7.  
  8. CALLENTRY /* Before the first symbol */
  9.  
  10. struct ExecBase *SysBase;
  11. struct DosLibrary *DOSBase;
  12.  
  13. static LONG tinymain(void);
  14.  
  15. LONG entry(struct ExecBase *sysbase)
  16. {
  17.     LONG error=RETURN_FAIL;
  18.     SysBase=sysbase;
  19.     DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",39);
  20.     if(DOSBase!=NULL)
  21.     {
  22.     error=tinymain();
  23.     CloseLibrary((struct Library *)DOSBase);
  24.     }
  25.     return error;
  26. }
  27.  
  28. static LONG tinymain(void)
  29. {
  30.     STRPTR args[2]={ NULL, NULL };
  31.     struct RDArgs *rda;
  32.     BPTR dir;
  33.     LONG error=0;
  34.  
  35.     rda=ReadArgs("DEVICE/A,DIR/A",(IPTR *)args,NULL);
  36.     if(rda!=NULL)
  37.     {
  38.     dir=Lock(args[1],SHARED_LOCK);
  39.     if(dir)
  40.     {
  41.         STRPTR s=args[0];
  42.         while(*s)
  43.         if(*s++==':')
  44.             s[-1]=0;
  45.         AssignLock(args[0],dir);
  46.     }
  47.     FreeArgs(rda);
  48.     }else
  49.     error=RETURN_FAIL;
  50.     if(error)
  51.     PrintFault(IoErr(),"Assign");
  52.     return error;
  53. }
  54.